#include "FreeEarthQt.h"

#include <FreeEarth/IFreeEarth.h>
#include <x3manager/objptr.h>
#include "FreeMainWindow.h"

CFreeEarthQt::CFreeEarthQt() 
	: m_pFreeMainWindow(new CFreeMainWindow())
{

}

CFreeEarthQt::~CFreeEarthQt()
{
	delete m_pFreeMainWindow;
	m_pFreeMainWindow = NULL;
}

bool CFreeEarthQt::Initialize(std::string strDataPath /*= ""*/)
{
	x3::Object<IFreeEarth> pFreeEarth(clsidFreeEarth);
	if (!pFreeEarth.valid())
	{
		return false;
	}

	pFreeEarth->Initialize(strDataPath);

	m_pFreeMainWindow->Initialize(pFreeEarth->GetRenderContext());

	return true;
}

bool CFreeEarthQt::Uninitialize()
{
	if (m_pFreeMainWindow == NULL)
	{
		return false;
	}

	m_pFreeMainWindow->UnInitialize();

	x3::Object<IFreeEarth> pFreeEarth(clsidFreeEarth);
	if (!pFreeEarth.valid())
	{
		return false;
	}

	pFreeEarth->Uninitialize();

	return true;
}


